<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:php="http://php.net/xsl"
	version="1.0">

	<xsl:include href="../common/layout.xsl"/>
	<xsl:include href="../common/passport.xsl"/>

	<!-- XHTML Output -->
	<xsl:template match="//platcode">
		<html>
			<xsl:call-template name="header"/>
			<body>
				<xsl:call-template name="passport-logo"/>
				<div class="user-bar">
					<ul>
						<li>
							<a href="{$base-url}">
								<xsl:value-of select="php:function('lang','base_name')"/>
							</a>
						</li>
						<xsl:choose>
							<xsl:when test="$session-name">
								<xsl:call-template name="session-bar"/>
							</xsl:when>
							<xsl:otherwise>
								<li>
									<a href="/account/login">
										<xsl:value-of select="php:function('lang','account_enter')"/>
									</a>
								</li>
							</xsl:otherwise>
						</xsl:choose>
					</ul>
				</div>
				<div id="passport" class="board">
					<xsl:apply-templates select="person"/>
					<xsl:apply-templates select="session-error"/>
				</div>
			</body>
		</html>
	</xsl:template>

	<!-- Session Error -->
	<xsl:template match="session-error">
		<div class="info">
			<h1>
				<xsl:value-of select="name"/>
			</h1>
			<p>
				<xsl:value-of select="err-msg"/>
			</p>
		</div>
	</xsl:template>

	<!-- Passport Info -->
	<xsl:template match="person">
		<div class="info">
			<h1>
				<xsl:value-of select="username"/>
			</h1>
			<div class="pic">
				<xsl:call-template name="view-userpic"/>
			</div>
			<dl>
				<ul>
					<xsl:if test="$session-name = username">
						<li class="right">
							<a href="/account/edit">
								<xsl:value-of select="php:function('lang','account_update')"/>
							</a>
						</li>
					</xsl:if>
					<li>
						<dt>
							<xsl:value-of select="php:function('lang','nickname')"/>
						</dt>
						<dd>
							<xsl:call-template name="passport-item">
								<xsl:with-param name="value" select="nickname"/>
							</xsl:call-template>
						</dd>
					</li>
					<li>
						<dt>
							<xsl:value-of select="php:function('lang','fullname')"/>
						</dt>
						<dd>
							<xsl:call-template name="passport-item">
								<xsl:with-param name="value" select="fullname"/>
							</xsl:call-template>
						</dd>
					</li>
					<li>
						<xsl:value-of select="dob"/>
					</li>
					<li>
						<xsl:value-of select="gender"/>
					</li>
					<li>
						<xsl:value-of select="postcode"/>
					</li>
					<li>
						<xsl:value-of select="country"/>
					</li>
					<li>
						<xsl:value-of select="lang"/>
					</li>
					<li>
						<xsl:value-of select="timezone"/>
					</li>
					<li>
						<xsl:value-of select="date_reg"/>
					</li>
					<li>
						<xsl:value-of select="last_visit"/>
					</li>
				</ul>
			</dl>
		</div>
	</xsl:template>

	<!-- Passport Item -->
	<xsl:template name="passport-item">
		<xsl:param name="value"/>
		<xsl:choose>
			<xsl:when test="$value">
				<xsl:value-of select="$value"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:attribute name="class">grey</xsl:attribute>
				<xsl:value-of select="php:function('lang','empty')"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

</xsl:stylesheet>
